﻿using System.Security.Cryptography;
using System.Text;

namespace ThirdClient
{
	public class Md5Helper
	{
		public static string ComputeMd5Hash(string input)
		{
			// 创建 MD5 对象
			using (var md5 = MD5.Create())
			{
				// 将输入字符串转换为字节数组
				byte[] inputBytes = Encoding.UTF8.GetBytes(input);

				// 计算哈希值
				byte[] hashBytes = md5.ComputeHash(inputBytes);

				// 将哈希值转换为十六进制字符串
				StringBuilder sb = new StringBuilder();
				for (int i = 0; i < hashBytes.Length; i++)
				{
					sb.Append(hashBytes[i].ToString("x2")); // 转换为小写的十六进制
				}

				return sb.ToString();
			}
		}
	}
}
